#!/usr/bin/python3
# -*- coding:utf-8 -*-
""""
@Author: 李吉凯
@Email: lijk34925@hundsun.com
@Time: 2022/11/24 14:55
@File: 产品风险评估配置.py
"""

from time import sleep

from qturboframe.lib.utils.by import By
from BladeFerm.Lib.Common import data_processing
from BladeFerm.hui2_app import FE
from 基础公共脚本.公共方法_hui2 import open_menu
from 基础公共脚本.步骤检查_hui2 import check_ele_text


@data_processing
def product_risk_review_config(input_data=None, ui_expect=None):
    # 进入 风险等级查询 菜单 客户风险评估/风险评估方案
    open_menu({'子系统名称': '反洗钱系统', '菜单名称': '产品风险评估/产品风险评估配置'})

    # 点击打开 等级区间方案
    list_obj = FE.list(idname={By.CSS_SELECTOR: 'div.h-tabs-nav-container'})
    list_obj.click('等级区间配置')

    # 点击 编辑
    FE.button("修改").click()

    FE.radioes("产品风险类型").set_value(input_data.pop("风险类型"))

    # 数值填充
    table = FE.table_base(idname={'xpath': './/div[contains(@class, "h-editgird-wrapper")]'
                                        '//div[@class="h-editgird-body"]/table'})
    for key, values in input_data.items():
        table.auto_fill_row(target_row=int(key), input_data=values, td_index=1)

    # 点击 确认
    FE.button(idname={'xpath': '//div[contains(@class, "search-wrap")]/button/span[contains(text(), "保存")]'}).click()
    sleep(0.5)

    check_ele_text(ui_expect=ui_expect)
